# -*- coding: utf-8 -*-
"""
@version: 1.0
@author: Pyma
@file: payinfo_filters
@time: 2019/12/18 22:27
"""
# 导入过滤器 判断用户是不是购买过付费资讯
from django import template
from apps.payinfo.models import PayinfOrder

register = template.Library()
# 注册为过滤器
@register.filter
def is_buyed(payinfo, user):
    if user.is_authenticated:
        result = PayinfOrder.objects.filter(payinfo=payinfo, buyer=user, status=2).exists()
        return result
    else:
        return False
